{% extends 'default/base.html' %}
{% block content %}
    {#    {% load auth %} todo #}


    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5> 服务器授权信息 </h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    {% include "auth/active.html" %}
                    <br/>
                    <div class="wrapper wrapper-content">
                        <div class="row">
                            {% include "auth/ztree_js.html"  %}
                            <div class="col-lg-9">
                                <div class="ibox float-e-margins">
                                    <div class="ibox-title">
                                        <h5>{{ user_obj.username }}- 授权服务器数量(<span class="text-danger"> {{ all_auth_node_count }} </span>)台</h5>
                                    </div>
                                    <div class="ibox-content">
                                        <table class="table table-bordered">
                                            <thead>
                                            <tr>
                                                <th>ip</th>
                                                <th>主机名</th>
                                                <th>权限</th>
                                                <th>所属项目</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            {% for i in all_auth_node %}
                                                <tbody>
                                                <tr>
                                                    <td>{{ i.node.eth1 }}</td>
                                                    <td>{% if i.node.node_name %}{{ i.node.node_name }}{% endif %}</td>
                                                    <td>
                                                        {% if i.auth %}管理员{% else %}普通用户{% endif %}
                                                    </td>
                                                    <td>{{ i.project }}</td>
                                                    <td>
                                                        {% if i.auth %}
                                                            <a href="/auth/host/del_host/{{ i.id }}/"
                                                               class="btn btn-xs btn-success">取消权限</a>
                                                        {% else %}
                                                            <a href="{% url 'host_permission_create' hostip=i.node.eth1 userpk=user_obj.pk %}"
                                                               class="btn btn-xs btn-success">添加权限</a>
                                                        {% endif %}
                                                    </td>
                                                </tr>
                                                </tbody>
                                            {% endfor %}
                                        </table>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


{% endblock %}
